package com.shadow.manager.dataManager
{
	import com.shadow.dataentities.systemdata.BuildingEntity;
	
	import flash.utils.Dictionary;

	/**
	 *商店建筑管理器 
	 * @author Administrator
	 * 
	 */	
	public class ShopBuildingsManager
	{
		private static var _instance:ShopBuildingsManager;
		private var _shop_buildings:Array;
		private var _buildingDic:Dictionary;
		public function ShopBuildingsManager(value:Singleton)
		{
			
		}

		public static function getInstance():ShopBuildingsManager
		{
			if(ShopBuildingsManager._instance == null)
			{
				ShopBuildingsManager._instance = new ShopBuildingsManager(new Singleton);
				ShopBuildingsManager._instance.init();
			}
			
			return ShopBuildingsManager._instance;
		}
		
		private function init():void
		{
			_shop_buildings = new Array();
			_buildingDic = new Dictionary();
		}
		
		/**
		 *获取商店建筑 
		 * @return 
		 * 
		 */		
		public function get shopBuildings():Array
		{
			return this._shop_buildings;
		}
		
		/**
		 * 根据建筑id获取数据
		 * @return 
		 * 
		 */		
		public function getBuildByID(id:int):BuildingEntity
		{
			return _buildingDic[id]
		}
		
		/**
		 *设置商店建筑数据 
		 * @param shopBuildings
		 * 
		 */		
		public function setData(shopBuildings:Object):void
		{
			var building:Object;
			var buildingEntity:BuildingEntity;

			for each(building in shopBuildings)
			{
				buildingEntity = new BuildingEntity(building);
				_buildingDic[buildingEntity.id.toString()] = buildingEntity;
				_shop_buildings.push(buildingEntity);
			}
		}
	}
}

class Singleton 
{
	
	
}